package com.cskaoyan.wxcontroller;

import com.cskaoyan.bean.baseresultVO.BaseRespVo;
import com.cskaoyan.bean.domain.FeedBack;
import com.cskaoyan.bean.domain.User;
import com.cskaoyan.service.FeedBackService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

/**
 * @author looper
 * @
 **/
@RestController
@RequestMapping("/wx/feedback")
public class WxFeedback {
    @Autowired
    FeedBackService service;


    @PostMapping("submit")
    public BaseRespVo getSubmit(@RequestBody FeedBack feedBack) {

        Subject subject = SecurityUtils.getSubject();
        User user = (User) subject.getPrincipals().getPrimaryPrincipal();
        feedBack.setUserId(user.getId());
        feedBack.setUsername(user.getUsername());
        feedBack.setAddTime(LocalDateTime.now());
        feedBack.setUpdateTime(LocalDateTime.now());
        //状态不知道是啥
        // TODO: 2021/12/3 setStatus
        feedBack.setStatus(101);
        Integer code = service.insertFeedBack(feedBack);
        return BaseRespVo.ok(null);


    }
}
